import React from "react";


interface PageContentProps{
    mouseMove:any
}

class Mouse extends React.Component<PageContentProps> {

    state = {
        x : 0,
        y : 0
    }
    handleMouseMove = (e:any) =>{
        this.setState({
            x: e.clientX,
            y: e.clientY
        })
    }
    componentDidMount(){
        window.addEventListener("mousemove",this.handleMouseMove)
    }
 
    render() {
        return this.props.mouseMove(this.state) 
    }

    componentWillUnmount(){
        window.removeEventListener("mousemove",this.handleMouseMove)
    }
}

export default Mouse;